<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="signupForm">
						<input id="id" name="id"  type="hidden">
							<div class="form-group">还款人员：<span th:text="${loanApply.realName}"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:red">所有信息谨慎填写，确认无误后，点击【生成账单】将清除之前的记录，重新补录新的还款账单</span></div>
							<div class="form-group">	
								<label class="col-sm-3 control-label">放款金额：</label>
								<div class="col-sm-3">
									<input id="loanAmount" name="loanAmount" th:value="${loanApply.loanAmount}" class="form-control" type="text">
								</div>
								<label class="col-sm-3 control-label">放款利息：</label>
								<div class="col-sm-3">
									<input id="remark1" name="remark1" th:value="${loanApply.remark1}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">	
								<label class="col-sm-3 control-label" >放款利率：</label>
								<div class="col-sm-3">
									<input id="loanRate" name="loanRate"  th:value="${loanApply.loanRate}" class="form-control" type="text">
								</div>
								<label class="col-sm-3 control-label">【填写天数】放款天数：</label>
								<div class="col-sm-3">
									<input id="loanPeriod" name="loanPeriod" th:value="${loanApply.loanPeriod}" class="form-control" type="text">
								</div>
							</div>
						</form>
					</div>
					<br/>
					<div class="form-group">
						<input id="userIdValue" th:value="${loanApply.id}" type="hidden"/>
						<div class="col-sm-10 col-sm-offset-1" style="text-align:right" >
						<span style="color:red" th:text="${loanApply.realName}"></span> 
								第一期：每日本金：【<span style="color:red"  th:text="${repayInfo.remark1}"></span>】&nbsp;
						 		     每日利息：【<span style="color:red"  th:text="${repayInfo.remark2}"></span>】&nbsp;】
						 		     第一期计算天数：【<span style="color:red"  th:text="${repayInfo.remark3}"></span>】&nbsp;
							<button class="btn btn-primary"  th:onclick="'javascript:PassBill()'">生成账单</button>
						</div>
					</div>
				</div>
			</div>
	</div>
	
	<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="signupForm">
						<input id="id" name="id"  type="hidden">
							<div class="form-group">
								<label  style="text-align:center" class="col-sm-3 control-label">还款期数：</label>
								<label  style="text-align:center" class="col-sm-3 control-label">还款金额：</label>
								<label  style="text-align:center" class="col-sm-3 control-label">还款时间：</label>
								<label  style="text-align:center" class="col-sm-3 control-label">还款状态：</label>
							</div>
							<div class="form-group" th:each="repay:${repays}">	
									<label style="text-align:center" class="col-sm-3 control-label">第<span th:text="${repay.period}"></span>期</label>
									<label style="text-align:center" class="col-sm-3 control-label" th:text="${repay.amt}"></label>
									<label style="text-align:center" class="col-sm-3 control-label" th:text="${#dates.format(repay.repayTime, 'yyyy-MM-dd')}"></label>
									<label style="text-align:center" class="col-sm-3 control-label">
									<span th:if="${repay.status} eq 0"><span style="color: red;">未还款</span></span>
									<span th:if="${repay.status} eq 1"><span style="color:#0d3cf3;">已还款</span></span>
									<span th:if="${repay.status} eq 2"><span style="color:#f30d55;">已逾期</span></span>
									</label>
							</div>
						</form>
					</div>
				</div>
			</div>
	</div>
	</div>
	<div th:include="include::footer"></div>
	<script>
	function PassBill(){
		var id=$("#userIdValue").val();
		var loanAmount=$("#loanAmount").val();
		var remark1=$("#remark1").val();
		var loanRate=$("#loanRate").val();
		var loanPeriod=$("#loanPeriod").val();
		$.ajax({
			cache : true,
			type : "POST",
			url : "/system/loanApply/resetbill",
			data : {"id":id,"loanAmount":loanAmount,"remark1":remark1,"loanRate":loanRate,"loanPeriod":loanPeriod},
			async : false,
			error : function(request) {
				parent.layer.alert("Connection error");
			},
			success : function(data) {
				if (data.code == 0) {
					parent.layer.msg("账单生成成功");
					parent.reLoad();
					var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
					parent.layer.close(index);

				} else {
					parent.layer.alert(data.msg)
				}

			}
		});
		

	}
	</script>
</body>
</html>
